<template lang="html">
    <div class="wrapper">
        <swiper :options="swiperOption" v-if="showSwiper">
          <!-- slides -->
          <swiper-slide v-for="item of list" :key="item.id">
              <img class="swiper-img" :src="item.imgUrl" alt="">
          </swiper-slide>

          <!-- Optional controls -->
          <div class="swiper-pagination"  slot="pagination"></div>

        </swiper>
    </div>

</template>

<script>
export default {
	name: 'HomeSwiper',
	data() {
		return {
			swiperOption: {
				// some swiper options/calRlbacks
				// 所有的参数同 swiper 官方 api 参数
				pagination: '.swiper-pagination',
				loop: true
			}
		}
	},
	props: {
		list: Array
	},
	computed: {
		showSwiper() {
			return this.list.length
		}
	}
}
</script>

<style lang="scss" scoped>
.wrapper /deep/ .swiper-pagination-bullet-active {
    background: #fff;
}
.wrapper {
    width: 100%;
    height: 0;
    overflow: hidden;
    padding-bottom: 31.50%;
    background: #ddd;

    .swiper-img {
        width: 100%;
    }

}
</style>
